﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="SPExpressionBuilderDesigner.cs" company="Lambros Vasiliou">
//   Copyright © 2010
// </copyright>
// <summary>
//   Design-time editor for the SharePoint Expression Builder.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace SPExpressions
{
    using System.Web.UI.Design;

    /// <summary>
    /// Design-time editor for the SharePoint Expression Builder.
    /// </summary>
    public class SPExpressionBuilderDesigner : ExpressionEditor
    {
        /// <summary>
        /// Evaluates an expression string and provides the design-time value for a control property.
        /// </summary>
        /// <returns>
        /// The object referenced by the evaluated expression string, if the expression evaluation succeeded; otherwise, null.
        /// </returns>
        /// <param name="expression">An expression string to evaluate. The expression does not include the expression prefix.
        /// </param><param name="parseTimeData">An object containing additional parsing information for evaluating <paramref name="expression"/>. This typically is provided by the expression builder.
        /// </param><param name="propertyType">The type of the control property to which <paramref name="expression"/> is bound.
        /// </param><param name="serviceProvider">A service provider implementation supplied by the designer host, used to obtain additional design-time services.
        /// </param>
        public override object EvaluateExpression(string expression, object parseTimeData, System.Type propertyType, System.IServiceProvider serviceProvider)
        {
            return string.Format("SharePoint: {0}", SharePointExpressionBuilder.GetSharePointProperty(expression, true));
        }
    }
}
